<template>
  <div>
    <Chart :cdata="cdata" />
  </div>
</template>

<script>
import Chart from './chart.vue'
export default {
  data () {
    return {
      cdata: {
        category: [],
        lineData: [],
        barData: [],
        rateData: []
      }
    };
  },
  components: {
    Chart,
  },
  mounted () {
    // this.setData();
    this.getDemo()
  },
  methods: {
    getDemo(){
      this.$axios.get('./data.json')
      .then(res=>{
        this.cdata.category=res.data.id
        this.cdata.lineData=res.data.data11
        this.cdata.barData=res.data.data2l
      })
    }
    // 根据自己的业务情况修改
    // setData () {
    //   for (let i = 0; i < this.cdata.barData.length -1; i++) {
    //     let rate = Math.abs(this.cdata.barData[i] - this.cdata.lineData[i])/ this.cdata.lineData[i];//let rate = this.cdata.barData[i] / this.cdata.lineData[i];
    //     this.cdata.rateData.push(rate.toFixed(2));
    //   }
    // },
  }
};
</script>

<style lang="scss" scoped>
</style>
